/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.tommasi;

import br.gui.analise.jIAnaliseFatura;
import br.gui.faturamento.jIFatura;
import br.gui.faturamento.jIProducao;

/**
 *
 * @author Adriano
 */
public class jFPrincipal extends javax.swing.JFrame {

    /**
     * Creates new form jFPrincipal
     */
    public jFPrincipal() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPMenu = new javax.swing.JPanel();
        producaoButton = new javax.swing.JButton();
        faturaButton = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jPFundo = new javax.swing.JPanel();
        jPDisplay = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPMenu.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        producaoButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/util/imagens/menu/producao_menu.png"))); // NOI18N
        producaoButton.setToolTipText("Producao");
        producaoButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                producaoButtonActionPerformed(evt);
            }
        });

        faturaButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/util/imagens/menu/fatura.png"))); // NOI18N
        faturaButton.setToolTipText("Fatura");
        faturaButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                faturaButtonActionPerformed(evt);
            }
        });

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/util/imagens/menu/arquivo_menu.png"))); // NOI18N
        jButton1.setToolTipText("Analise de Fatura");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPMenuLayout = new javax.swing.GroupLayout(jPMenu);
        jPMenu.setLayout(jPMenuLayout);
        jPMenuLayout.setHorizontalGroup(
            jPMenuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPMenuLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(producaoButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(faturaButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton1)
                .addContainerGap(1141, Short.MAX_VALUE))
        );
        jPMenuLayout.setVerticalGroup(
            jPMenuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPMenuLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPMenuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButton1)
                    .addComponent(faturaButton)
                    .addComponent(producaoButton))
                .addContainerGap())
        );

        javax.swing.GroupLayout jPFundoLayout = new javax.swing.GroupLayout(jPFundo);
        jPFundo.setLayout(jPFundoLayout);
        jPFundoLayout.setHorizontalGroup(
            jPFundoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        jPFundoLayout.setVerticalGroup(
            jPFundoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 689, Short.MAX_VALUE)
        );

        jPDisplay.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        javax.swing.GroupLayout jPDisplayLayout = new javax.swing.GroupLayout(jPDisplay);
        jPDisplay.setLayout(jPDisplayLayout);
        jPDisplayLayout.setHorizontalGroup(
            jPDisplayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        jPDisplayLayout.setVerticalGroup(
            jPDisplayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 30, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPMenu, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPFundo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPDisplay, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPMenu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPFundo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPDisplay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void producaoButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_producaoButtonActionPerformed
        // TODO add your handling code here:
        abrirProducao();
    }//GEN-LAST:event_producaoButtonActionPerformed

    private void faturaButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_faturaButtonActionPerformed
        // TODO add your handling code here:
        abrirFatura();
    }//GEN-LAST:event_faturaButtonActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        abrirAnaliseFatura();
    }//GEN-LAST:event_jButton1ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(jFPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(jFPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(jFPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(jFPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new jFPrincipal().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton faturaButton;
    private javax.swing.JButton jButton1;
    private javax.swing.JPanel jPDisplay;
    private static javax.swing.JPanel jPFundo;
    private javax.swing.JPanel jPMenu;
    private javax.swing.JButton producaoButton;
    // End of variables declaration//GEN-END:variables
    
    private static jIProducao p;
    private static jIFatura f;
    private static jIAnaliseFatura af;
    
    public static void abrirProducao() {
        if(p == null){
            p = new jIProducao();
        }
        
        jPFundo.add(p);
        p.setVisible(true);
    }
    
    public static void fechaProducao(){
        jFPrincipal.p = null;
    }
    
    public static void abrirFatura(){
        if(f == null){
            f = new jIFatura();
        }
        
        jPFundo.add(f);
        f.setVisible(true);
    }
    
    public static void fechaFatura(){
        jFPrincipal.f = null;
    }
    
    public static void abrirAnaliseFatura(){
        if(af == null){
            af = new jIAnaliseFatura();
        }
        jPFundo.add(af);
        af.setVisible(true);
    }
    
    public static void fechaAnaliseFatura(){
        jFPrincipal.af = null;
    }
}
